<template>
	<u-popup v-model="gemShow" mode="bottom" @close='close'>
		<view class="diy-gem-list">
			<diy-scroll :Empty='gemList.length ? false : true' :status='status' @scrolltolower='getgoods'
				@refresherrefresh='refresherrefresh'>
				<view class="item" v-for="(item,index) in gemList" :key="index" :style="{
						'background-image':index < 3 ? 'url(' + $util.img(`${'/static/img/lv/top'+ ( Number(index) + 1) + '.png'}`) + ')' : ''
					}">
					<view class="i-left" >
						<u-image class="l-u-image" :src="$util.img('/static/img/ranking/1.png')" v-if="index == 0"
							mode="aspectFit" width="60" height='60' duration='600'></u-image>
						<u-image class="l-u-image" :src="$util.img('/static/img/ranking/2.png')" v-else-if="index == 1"
							mode="aspectFit" width="60" height='60' duration='600'></u-image>
						<u-image class="l-u-image" :src="$util.img('/static/img/ranking/3.png')" v-else-if="index == 2"
							mode="aspectFit" width="60" height='60' duration='600'></u-image>
						<view class="tips-num" v-else>{{index + 1}}</view>
						<u-avatar :src="$util.img(item.avatar)" width="60" height="60"></u-avatar>
						<view class="ul-box">
							<view class="id">ID：{{item.id}}</view>
							<view class="num">
								<image :src="$util.img('/static/img/card/宝石.png')" mode="widthFix"></image>
								<view>{{item.balance}}</view>
							</view>
						</view>
					</view>
					<view class="i-right" @click="open(item)">
						<text>联系他</text>
						<u-icon name="arrow-right" size="24" color="rgba(0,0,0,.4)" style="margin-top: 3rpx;"></u-icon>
					</view>
				</view>
			</diy-scroll>
		</view>
	</u-popup>
</template>

<script>
	export default {
		data() {
			return {
				// 弹窗打开
				gemShow: false,
				//排行榜
				gemList: [],
				//下面的数据
				status: 'loadmore',
				//加载配置
				page: {
					page: 1,
					page_size: 10,
				},
			}
		},
		props: {
			show: {
				type: [String, Boolean],
				default: false
			},
		},
		watch: {
			show: {
				handler(newval, oldVal) {
					if (this.show) {
						this.$nextTick(()=>{
							this.refresherrefresh()
						})
					}
					this.gemShow = this.show;
				},
				immediate: true
			}
		},
		mounted() {},
		methods: {
			// 下拉刷新的数据
			refresherrefresh(callback) {
				this.page = {
						page: 1,
						page_size: 8,
					},
					this.getgoods(callback);
			},
			// 弹窗关闭
			close() {
				this.$emit('close')
			},
			//触底获取数据
			getgoods(callback) {
				this.$http.asyncSendrequest({
					url: '/profile/GemRanking',
					data: {
						type: 1,
						...this.page
					},
					success: res => {
						if (res.code == '0') {
							if (this.page.page == 1) this.gemList = [];
							if (res.data.length) {
								this.gemList = this.gemList.concat(res.data);
								this.page.page += 1;
							} else {
								//下面加载的文字
								this.status = 'nomore'
							}
							if (typeof callback == 'function') callback();
							this.loding = false;
						}
					}
				})
			},
			open(item){
				this.$emit('setContactShow',item)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.diy-gem-list {
		height: 90vh;
		background: #fff;
		border-radius: 20rpx 20rpx 0 0;
		overflow: hidden;
		padding: 40rpx 0;

		.item {
			// margin: 0 0 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 140rpx;
			// background: rgba(0,0,0,.05);
			// padding:0 30rpx;
			background-repeat: no-repeat;
			background-size: auto 100%;
			.i-left {
				display: flex;
				align-items: center;

				margin-left: 40rpx;
				.l-u-image {
					margin-right: 40rpx;
					width: 60rpx;
					height: 60rpx;
				}

				.tips-num {
					width: 60rpx;
					height: 60rpx;
					text-align: center;
					line-height: 60rpx;
					margin-right: 40rpx;
					font-size: 32rpx;
					font-weight: bold;
				}

				.ul-box {
					margin-left: 30rpx;

					.id {
						font-size: 26rpx;
					}

					.num {
						color: orangered;
						display: flex;
						align-items: center;
						margin-top: 10rpx;
						font-size: 26rpx;

						image {
							width: 30rpx;
							margin-right: 10rpx;
						}
					}
				}
			}

			.i-right {
				width: 150rpx;
				font-size: 24rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border: 1rpx solid rgba(0, 0, 0, .2);
				height: 40rpx;
				border-radius: 40rpx;
				margin-right: 40rpx;
			}
		}
	}
</style>